package com.yl.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum Warn {

    // 告警等级
    RED(1, "紧急"),
    YELLOW(2, "严重"),
    BLUE(3, "一般");

    private Integer level;
    private String name;

    /**
     * 根据告警等级获取告警对象
     */
    public static Warn getWarn(int level) {
        for (Warn warn : Warn.values()) {
            if (warn.level == level) {
                return warn;
            }
        }
        return null;
    }

    /**
     * 根据告警等级获取告警信息
     */
    public static String msg(int level) {
        for (Warn warn : Warn.values()) {
            if (warn.level == level) {
                return warn.getName() + "告警";
            }
        }
        return null;
    }

}
